package com.emns.service.user;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.emns.dao.UserMapper;
import com.emns.dao.ValidateMapper;
import com.emns.pojo.User;
import com.emns.pojo.Validate;


@Service
public class UserService {
	@Autowired 
	UserMapper um;
	@Autowired
	ValidateMapper vm;
	/**
	 * 登陆
	 * @param name
	 * @param pass
	 * @return
	 */
	public User login(String name,String pass){
		return um.Login(name, pass);
	}
	/**
	 * 查询管理员
	 * @return
	 */
	public List<User> queryAdminList(){
		return um.queryAdmin();
	}
	/**
	 * 修改密码
	 * @param newpass
	 * @param uid
	 * @return
	 */
	public int changPassword(String newpass,int uid){
		return um.changePassword(newpass, uid);
		
	}
	/**
	 * 修改默认有效期
	 * @param month
	 * @return
	 */
	public int updateMonth(int month){
		return vm.updateTime(month);
	}
	/**
	 * 查询有效日期
	 * @return
	 */
	public Validate queryValidate(){
		List<Validate> vList = vm.selectAll();
		return vList.get(0);
	}
	/**
	 * 添加手机端用户
	 * @param user
	 * @return
	 */
	public int addUserByMobile(User user){
		int result=um.insertSelective(user);
		return result;
	}
	public User getUserForMobile(String usercode){
		return um.LoginByC(usercode);
	}
}
